---
sidebar_label: OpenAI
---

import CodeBlock from "@theme/CodeBlock";
import ExampleOpenAI from "@examples/openai-completion-example/openai_completion_example.go";

# OpenAI
OpenAI offers a spectrum of models with different levels of power suitable for different tasks.

This example goes over how to use LangChain to interact with OpenAI models.

There are two options to set the the OpenAI key. 

1. We can do this by setting the environment variable OPENAI_API_KEY to the api key.

2. Or we can do it when initializing the wrapper along with other arguments.
   ```go
    model, err := openai.New(openai.WithToken(apiToken))
   ```

<CodeBlock language="go">{ExampleOpenAI}</CodeBlock>